<!--  -->
<template xmlns="" xmlns="">
  <div style="padding-top:100px">
    <div class="app-title-container title-position">
      <modules-title titleName="检验任务">
        <template slot="btn">

        </template>
      </modules-title>
    </div>
    <div style="padding:20px">
      <!-- 搜索 -->
      <el-form :inline="true">
        <el-form-item style="margin-right:40px">
          <el-select v-model="queryParams.search_type" @change="handlSearch" placeholder="所有状态"
                     size="small">
            <el-option label="所有" :value="0"></el-option>
            <el-option label="我检验的" :value="1"></el-option>
            <el-option label="我分配的" :value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="请验类型" style="margin-right:40px">
          <el-select v-model="queryParams.inspection_type" @change="handlInspection"
                     placeholder="请验类型" size="small">
            <el-option v-for="item in demandSourceOptions" :key="item.id" :label="item.dict_val"
                       :value="item.dict_key"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目" style="margin-right:40px">
          <el-select v-model="queryParams.project_id" @change="handlProject" filterable
                     placeholder="项目名称" size="small">
            <el-option v-for="dict in project" :key="dict.project_id"
                       :label="`${dict.project_name}(${ dict.project_phases_id === '1' ? '临床前研究' : '临床研究'})`"
                       :value="dict.id"/>
          </el-select>
        </el-form-item>
        <el-form-item label="状态" style="margin-right:40px">
          <el-select v-model="queryParams.inspection_status" @change="handlSatus" size="small">
            <el-option v-for="dict in inspection" :key="dict.value" :label="dict.label"
                       :value="dict.value"/>
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button class="filter-item" type="primary" size="small" @click="handleQuery">搜索
          </el-button>
          <el-button plain @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <!--表格-->
      <el-table :data="myWaitList" size="medium" border @row-click="aloneClick"
                :cell-style="cellStyle">
        <el-table-column prop="inspection_no" label="检验单号" align="center"/>
        <el-table-column prop="sample_info.name" label="检品名称" header-align="center"
                         :show-overflow-tooltip="true"/>

        <el-table-column prop="inspection_type_name" label="请验类型" align="center"/>

        <el-table-column prop="creator_name" label="请验人" align="center"/>

        <el-table-column label="请验时间" align="center">
          <template #default="{row}">
            {{ dateFormat1('yyyy-mm-dd',row.created_at)}}
          </template>
        </el-table-column>
        <el-table-column label="检验负责人" align="center">
          <template #default="{row}">
            <span v-if="row.inspection_header !== null">{{row.inspection_header.name}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="inspection_user_name" label="检验人" align="center">
          <template #default="{row}">
            <span v-if="row.inspection_joiner !== null && row.inspection_joiner[0]">
              {{row.inspection_joiner[0].name}}
            </span>
            <span v-if=" row.inspection_joiner !== null && row.inspection_joiner.length > 1 ">
              等{{row.inspection_joiner.length}}人
            </span>
          </template>
        </el-table-column>

        <el-table-column prop="project_name" label="项目名称" :show-overflow-tooltip="true" header-align="center"/>

        <el-table-column label="状态" align="center">
          <template #default="{row}">
            {{status(row.inspection_task_status)}}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="250" header-align="center">
          <template #default="{row}">

            <el-button type="text" size="medium"
                       v-hasPermi="{v:['sampleInspection:dealWith:distri'],isF:(row.if_do_return_sample === 0 && row.if_return_sample === 1)}"
                       @click="handlReturn(row)">返样
            </el-button>
            <el-button type="text" size="medium"
                       v-hasPermi="{v:['sampleInspection:dealWith:distri'],isF:(row.if_do_return_sample === 2 && row.if_return_sample === 1)}"
                       @click="handlReturnEdit(row)">返样编辑
            </el-button>

            <el-button type="text" size="medium"
                       v-hasPermi="{v:['sampleInspection:dealWith:distri'],isF:(row.inspection_task_status === 0 )}"
                       @click="handlDistri(row)">分配
            </el-button>

            <el-button type="text" size="medium"
                       v-if="(row.inspection_task_status === 1 || row.inspection_task_status === 0)
               && row.if_reserve_sample === 1 &&
                ((row.inspection_header && row.inspection_header.id === userInfo) ||
                (row.inspection_joiner && handlAbc(row.inspection_joiner)))"
                       @click="handlReten(row)" :disabled="row.reserve_sample_opt">
              <span v-if="!row.reserve_sample_opt">留样</span>
              <span v-else>已留样</span>
            </el-button>

            <el-button type="text" size="medium"
                       v-if="row.inspection_task_status === 1 && row.inspection_header && row.inspection_header.id === userInfo"
                       @click="handlResults(row)">提交检验结果
            </el-button>

            <el-button type="text" size="medium"
                       v-if="row.inspection_task_status === 4 && ((row.inspection_header && row.inspection_header.id === userInfo) ||
                (row.inspection_joiner && handlAbc(row.inspection_joiner)))"
                       @click="handlReport(row.id,row)">查看报告
            </el-button>

            <el-button type="text" size="medium" @click="cancelOperation(row)"
                       v-if="row.result_check && row.result_check.Cancelable && row.result_check.check_creator_id == userInfo">
              撤销审批
            </el-button>
          </template>
        </el-table-column>
      </el-table>

    </div>

    <!--页码-->
    <pagination style="display:flex;justify-content:flex-end;" :total="total"
                :page.sync="queryParams.pager.skip" :limit.sync="queryParams.pager.limit"
                @pagination="pagination"/>

    <!--对话框 -->
    <el-dialog :title="title" :visible.sync="open" :width="widthPx" append-to-body
               :before-close="cancel" :close-on-click-modal="false" v-if="open">
      <el-alert style="margin-bottom: 20px" v-if="booleInfo && openBoole === 4" :closable="false"
                title="有必填未填写请切换表格填写" type="error"></el-alert>
      <el-form ref="formOpen" :model="formOpen" :rules="rules"
               label-width="100px" size="small">
        <!-- 请验申请审批 1-->
        <div v-if="openBoole === 1">
          <el-form-item label="审批意见" prop="check_advice">
            <el-input v-model="formOpen.check_advice" placeholder="请输入审批意见"/>
          </el-form-item>
        </div>

        <!-- 请选择检验员 2-->
        <div v-else-if="openBoole === 2">
          <el-form-item label="是否留样" :required="isHaveWho" prop="storage_conditions"
                        v-if="rowList.if_reserve_sample === 2 && rowList.inspection_type !== 'inspection_type_wd' ">
            <el-input v-model="formOpen.storage_conditions" :disabled="formOpen.if_reserve_sample ===2"
                      placeholder="请输入贮存条件">
              <template slot="prepend">
                <el-radio-group v-model="formOpen.if_reserve_sample" @change="onChangeRadio">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="2">否</el-radio>
                </el-radio-group>
                <span style="padding-left:10px">贮存条件</span>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label="负责人" prop="inspection_user_id">
            <el-select v-model="formOpen.inspection_user_id" placeholder="选择负责人" style="width:100%"
                       @change="onChangeInsp">
              <el-option v-for="(item,index) in inspector" :key="index" :label="item.name"
                         :value="item.id"/>
            </el-select>
          </el-form-item>
          <el-form-item label="检验员" prop="participants_user_id">
            <el-select v-model="formOpen.participants_user_id" placeholder="选择检验员" multiple
                       @change="onChangeSelect" style="width:100%">
              <el-option v-for="(item,index) in participants" :key="index" :label="item.name"
                         :value="item.id"/>
            </el-select>
          </el-form-item>
          <template v-if="rowList.inspection_type === 'inspection_type_wd' ">
            <el-form-item label="检验期限" prop="inspection_date">
              <el-date-picker v-model="formOpen.inspection_date" type="date" value-format="yyyy-MM-dd"
                              :picker-options="pickerOption1" @change="onChangeTime2" placeholder="请选择检验期限"
                              style="width:100%"/>
            </el-form-item>
            <el-form-item label="检验依据" prop="quality_standard_file">
              <el-row :gutter="20" style="display: flex;flex-wrap: nowrap">
                <el-col :span="12">
                  <el-radio-group v-model="formOpen.quality_standard_type" @change="handlRadio">
                    <el-radio :label="1">选择已有质量标准</el-radio>
                    <el-radio :label="2">上传新质量标准</el-radio>
                  </el-radio-group>
                </el-col>
                <el-col :span="12" v-if="formOpen.quality_standard_type === 1">
                  <el-row>
                    <el-col :span="16">
                      <el-select v-model="formOpen.quality_standard_id" style="width:100%"
                                 @change="onChangeQuality" placeholder="请选择检验依据">
                        <el-option v-for="item in projectList" :key="item.id"
                                   :label="item.quality_standard_name" :value="item.id"/>
                      </el-select>
                    </el-col>
                    <el-col :span="8" style="text-align: right">
                      <el-dropdown>
                        <span class="el-dropdown-link">
                          查看检验依据<i class="el-icon-arrow-down el-icon--right"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                          <div v-if="fileListQuality.length === 0"
                               style="width: 200px;padding:10px 5px;font-size: 12px"> 暂无
                          </div>
                          <div v-else style="width: 200px">
                            <el-dropdown-item v-for="item in fileListQuality" :key="item.id"
                                              @click.native="openFile(item)"
                                              style="cursor: pointer;color: #409eff;">
                              {{item.old_name}}{{item.suffix}}
                            </el-dropdown-item>
                          </div>
                        </el-dropdown-menu>
                      </el-dropdown>
                    </el-col>
                  </el-row>

                </el-col>
                <el-col :span="12" v-else-if="formOpen.quality_standard_type ===2">
                  <el-row>
                    <el-col :span="12">
                      <upload ref="uploadFiles" :showList="false" @uploadSuccess="uploadSuccess" :tipShow="false"
                              btnTitle="上传检验依据"/>
                    </el-col>
                    <el-col :span="12">
                      <el-dropdown v-if="formOpen.quality_standard_file.length > 0">
                        <span class="el-dropdown-link">
                          查看检验依据<i class="el-icon-arrow-down el-icon--right"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                          <el-dropdown-item v-for="item in formOpen.quality_standard_file"
                                            :key="item.id">
                            <div
                              style="display: flex;align-items: center;justify-content: space-between;width: 200px">
                              <div @click="openFile1(item)" style="cursor: pointer;color: #409eff;">
                                {{item.old_name}}{{item.suffix}}
                              </div>

                              <el-button type="text" style="color:red"
                                         @click.native.stop="handlDele(item)" icon="el-icon-delete">
                              </el-button>

                            </div>
                          </el-dropdown-item>
                        </el-dropdown-menu>
                      </el-dropdown>
                    </el-col>
                  </el-row>
                </el-col>
              </el-row>
            </el-form-item>
          </template>

        </div>

        <!-- 留样 3-->
        <div v-else-if="openBoole === 3">
          <el-form-item label="留样数量" prop="reserve_sample_num">
            <el-input v-model="formOpen.reserve_sample_num" @change="handlSampleNum"
                      placeholder="请输入留样数量"/>
          </el-form-item>
          <el-form-item label="留样包装" prop="packaging">
            <el-autocomplete
              v-model.trim="formOpen.packaging" :fetch-suggestions="querySearchAsync"
              placeholder="请选择(可输入)留样包装" @select="handlPackaging" style="width:100%">
              <template slot-scope="{ item }">
                <div class="product-item">
                  <div class="name">
                    <span>{{ item.packing_material_name }}</span>
                  </div>
                </div>
              </template>
            </el-autocomplete>
          </el-form-item>
          <el-form-item label="留样位置" prop="location_name">
            <!--            <el-input v-model="formOpen.location_name" placeholder="请输入留样位置" />-->
            <el-select v-model="formOpen.location_name" :filter-method="remoteMethods" clearable
                       @change="selectClick" filterable
                       placeholder="请选择(可输入)留样位置" style="width:100%">
              <el-option
                placeholder="请输入留样位置"
                v-for="(item,idx) in locationList"
                :key="idx"
                :label="item.sample_location_name"
                :value="item.sample_location_name"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="留样有效期" prop="reserve_sample_date">
            <el-date-picker v-model="formOpen.reserve_sample_date" type="date"
                            :picker-options="pickerOption" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"
                            style="width:100%">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="留样备注">
            <el-input v-model="formOpen.remark" placeholder="请输入留样备注"/>
          </el-form-item>
        </div>

        <!-- 上传检验报告 4-->
        <div v-else-if="openBoole === 4" style="height: 600px;overflow-y:scroll ">
          <el-form-item label="检验结果/报告">
            <el-tabs v-model="activeNames" type="border-card">
              <!--              <el-tab-pane label="设置数据" name="setData">-->
              <!--&lt;!&ndash;                <setTable />&ndash;&gt;-->
              <!--              </el-tab-pane>-->
              <el-tab-pane :key="index" v-for="(item, index) in formOpen.tableResults.report" :label="item.batch_no"
                           :name="item.batch_no">
                <el-form-item label="检验结论">
                  <el-select v-if="!item.boole" v-model="item.inspection_conclusion" size="small" style="width:100%">
                    <el-option label="合格" :value="1"></el-option>
                    <el-option label="不合格" :value="2"></el-option>
                    <el-option label="无结论" :value="3"></el-option>
                  </el-select>
                  <div v-else>
                    <span v-if="item.inspection_conclusion === 1 ">合格</span>
                    <span v-if="item.inspection_conclusion === 2 ">不合格</span>
                    <span v-if="item.inspection_conclusion === 3 ">无结论</span>
                  </div>
                </el-form-item>
                <el-form-item label="实验数据" v-if="rowList.inspection_type === 'inspection_type_wd' "
                              label-width="125px">
                  <statisticalTable ref="statistical" :point="rowList.plan_point_info" :ruleForm="item.ruleForm"/>
                </el-form-item>
                <el-row :gutter="20">
                  <el-col :span="12">
                    <el-form-item label="文件编号" :prop="'tableResults.report.' + index + '.file_no'"
                                  :rules="[{required: true, message: '请输入文件编号', trigger: 'blur'}]">
                      <el-input v-if="!item.boole" v-model="item.file_no" placeholder="请输入文件编号"></el-input>
                      <span v-else>{{item.file_no}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="版本号" :prop="'tableResults.report.' + index + '.file_version'"
                                  :rules="[{required: true, message: '请输入版本号', trigger: 'blur'}]">
                      <el-input v-if="!item.boole" v-model="item.file_version" placeholder="请输入版本号"></el-input>
                      <span v-else>{{item.file_version}}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="检验结果" :prop="'tableResults.report.' + index + '.old_name'"
                              :rules="rules.old_name">
                  <div>
                    <upload v-if="!item.boole" :ref="'uploadResults'+ index" :limit="1"
                            :edit-list="item.old_name ?[item] : []"
                            @deleteSuccess="(val)=>{deleteSuccess(val,index)}"
                            @uploadSuccess="(val)=>{uploadSuccessResults(val,index)}"/>

                    <file-preview v-else :file-list="[item]" :fileBtnOption="['preview']"/>
                  </div>
                  <div v-if="item.boole">
                    <el-button type="text" @click.stop.native="handlFile(index)">
                      重置
                    </el-button>
                    <el-tooltip content="点击可重新填写、上传检验结果/报告" placement="bottom"
                                effect="light">
                      <i class="el-icon-question"></i>
                    </el-tooltip>
                  </div>
                </el-form-item>
              </el-tab-pane>
            </el-tabs>
          </el-form-item>

          <el-form-item label="计算表格" prop="tableResults.computation_sheet" style="margin-top: 20px">
            <upload-select ref="uploadEnclosure1" :edit-list="formOpen.tableResults.computation_sheet"
                           :fileType="['.xls', '.xlsx']" @selectSuccess="selectSuccess"/>
          </el-form-item>
          <el-form-item label="检验图谱" prop="tableResults.inspection_map">
            <upload-select ref="uploadEnclosure2" :edit-list="formOpen.tableResults.inspection_map"
                           @selectSuccess="selectSuccess1"/>
          </el-form-item>

        </div>

        <!--    返样 5    -->
        <div v-if="openBoole === 5">
          <el-form-item label="检品名称：">
            {{formOpen.name}}
          </el-form-item>
          <el-form-item label="送检量：">
            {{formOpen.sample_num}}/{{rowList.sample_info.unit}}
          </el-form-item>
          <el-form-item label="批号：">
            {{handlBath(rowList)}}
          </el-form-item>
          <el-form-item label="返样数量" prop="return_sample_check_num">
            <el-input v-model="formOpen.return_sample_check_num" placeholder="请输入返样数量">
              <template #append>
                <span>{{rowList.sample_info.unit}}</span>
              </template>
            </el-input>
          </el-form-item>
        </div>

      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button plain size="small" @click="cancel">取 消
        </el-button>
        <el-button v-if="openBoole === 1" type="warning" size="small" @click="refused">拒绝
        </el-button>
        <el-button size="small" type="primary" @click="submitForm">
          <span v-if="openBoole === 1">通过</span>
          <span v-else-if="openBoole === 2 || openBoole === 5">确定</span>
          <span v-else-if="openBoole === 3">保存</span>
          <span v-else-if="openBoole === 4">提交审批</span>
        </el-button>
      </div>
    </el-dialog>

    <!--查看报告 -->
    <el-dialog title="查看报告" :visible.sync="openReport" width="1200px" append-to-body
               :close-on-click-modal="false" v-if="openReport">
      <el-form ref="formOpen" :model="formOpen" label-width="100px" size="small">
        <div style="height: 600px;overflow-y:scroll ">
          <el-form-item label="检验结果/报告">
            <el-tabs v-model="activeNames" type="border-card">
              <el-tab-pane :key="index" v-for="(item, index) in formOpen.tableResults.report" :label="item.batch_no"
                           :name="item.batch_no">
                <el-form-item label="检验结论：">
                  <span v-if="item.inspection_conclusion === 1 ">合格</span>
                  <span v-if="item.inspection_conclusion === 2 ">不合格</span>
                  <span v-if="item.inspection_conclusion === 3 ">无结论</span>
                </el-form-item>
                <el-form-item label="稳定性统计数据：" v-if="rowList.inspection_type === 'inspection_type_wd' "
                              label-width="125px">
                  <statisticalDetails :point="rowList.plan_point_info" :detailForm="item.ruleForm"/>
                </el-form-item>
                <el-row :gutter="20">
                  <el-col :span="12">
                    <el-form-item label="文件编号：">
                      <span>{{item.file_no}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="版本号：">
                      <span>{{item.file_version}}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="检验结果：">
                  <file-preview :file-list="[item]" :fileBtnOption="['preview']"/>
                </el-form-item>
              </el-tab-pane>
            </el-tabs>
          </el-form-item>
          <el-form-item label="计算表格" prop="tableResults.computation_sheet" style="margin-top: 20px">
            <file-preview :file-list="formOpen.tableResults.computation_sheet" :fileBtnOption="['preview']"/>
          </el-form-item>
          <el-form-item label="检验图谱" prop="tableResults.inspection_map">
            <file-preview :file-list="formOpen.tableResults.inspection_map" :fileBtnOption="['preview']"/>
          </el-form-item>
        </div>

      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button plain size="small" @click="openReport = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import {
    myWait,
    projectName,
    applyCheck,
    reportCheck,
    undoCheck,
    allocation,
    samples,
    report,
    undo,
    viewReport,
    applyHeader,
    applyUser,
    applyEditorUpdate,
    lookInfoSet,
    projectNamesss,
    samplePackaging,
    sampleLocation,
    sampleLocationCreate,
    sampleReturn, sampleReturnUpdate, quality, viewQuality, sampleUpdate,
    sampleListTable, sampleListUpdate
  } from '@/api/sampleInspection'
  import userInfo from '@/views/user/profile/userInfo'
  import { fileDeleteFunc, filePreviewFun } from '@/utils/file'
  import Logo from '@/layout/components/Sidebar/Logo'

  export default {
    components: {
      statisticalTable: () => import('./tableList'),
      statisticalDetails: () => import('./tableDetails'),
      setTable:()=>import('./setTable')
    },
    data() {
      let CheckNum = (rule, value, callback) => {
        const r =  /(^$)|^[0-9]+(.[0-9]{1,3})?$/// 正整数
        // const r = /^(1|-?[1-9][0-9]*)(\.\d)?$/; //保留一位小数
        if (value === '') {
          callback(new Error('输入不能为空'))
        } else if (!r.test(value)) {
          callback(new Error('只能输入整数或者最多保留三位小数'))
        } else {
          if (value > this.rowList.sample_num) {
            callback(new Error('数量大于送检量'))
          } else {
            callback()
          }
        }
      }
      let checkStorage = (rule, value, callback) => {
        if (this.formOpen.if_reserve_sample === 1) {
          if (value === '') {
            callback(new Error('请输入贮存条件'))
          } else {
            callback()
          }
        } else {
          callback()
        }
      }
      let checkHandl = (rule, value, callback) => {
        if (this.formOpen.quality_standard_type === 1) {
          if (this.formOpen.quality_standard_id === '') {
            callback(new Error('请选择检验依据'))
          } else {
            callback()
          }
        } else if (this.formOpen.quality_standard_type === 2) {
          if (this.formOpen.quality_standard_file.length === 0) {
            callback(new Error('请上传检验依据'))
          } else {
            callback()
          }
        } else {
          callback()
        }
      }
      let checkHandl1 = (rule, value, callback) => {
        if (this.objData.fileList.length > 0 || this.objData.newFileList.length > 0) {
          callback()
        } else {
          callback(new Error('请上传计算表格'))
        }
      }
      let checkHandl2 = (rule, value, callback) => {
        if (this.objData1.fileList.length > 0 || this.objData1.newFileList.length > 0) {
          callback()
        } else {
          callback(new Error('请上传检验图谱'))
        }
      }
      let checkHandl3 = (rule, value, callback) => {
        let field = rule.field.split('.')[2]
        if (this.formOpen.tableResults.report[field].old_name === undefined) {
          callback(new Error('请上传检验结果'))
        } else {
          if (this.formOpen.tableResults.report[field].old_name === '') {
            callback(new Error('请上传检验结果'))
          } else {
            callback()
          }
        }
      }

      return {
        activeNames: null,
        basisData: {},
        queryParams: {
          inspection_type: undefined,
          project_id: '',
          inspection_status: -1,
          search_type: 0,
          pager: {
            limit: 10,
            skip: 1
          }
        },
        sample: [],
        myWaitList: [],
        total: 0,
        inspection: [
          //状态
          { label: ' 全部 ', value: -1 },
          { label: '待分配 ', value: 0 },
          { label: '检验中 ', value: 1 },
          { label: '结果审批中', value: 2 },
          { label: '结果审批拒绝', value: 3 },
          { label: '已结束 ', value: 4 },
          { label: '已撤销 ', value: 5 }
        ],
        inspector: [], //检验员
        participants: [],
        location: [],
        project: [],
        title: '',
        open: false,
        openBoole: 0,
        formOpen: {
          id: '0', //主键id
          check_status: undefined, //审批 1 通过  2 拒绝
          check_advice: '', //审批建议
          inspection_user_id: '', //分配的检验员的id
          inspection_user_name: '', //分配的检验员的名称
          reserve_sample_num: undefined, //留样的数量
          reserve_sample_date: '', //留样的有效期
          report: '', //报告内容
          participants_user_id: [], //参与人id
          participants_user_name: [], //参与人名字
          location_id: '', //位置id
          location_name: '', //位置name
          reserve_sample_no: '', //留样编号
          packaging: '', //留样包装
          inspection_conclusion: 1,
          remark: '',
          sample_num: null,
          return_sample_check_num: null,
          name: '',
          if_reserve_sample: 0,
          storage_conditions: '',
          quality_standard_type: 1,
          quality_standard_id: '',
          quality_standard_name: '',
          quality_standard_file: [],
          inspection_date: '',
          tableResults: {
            id: '',
            report: [],//
            computation_sheet: [], //计算表格
            inspection_map: []//  检验图谱
          },
          relation_plan_id: ''
        },
        rules: {
          check_advice: [
            { required: true, message: '请输入审批意见', trigger: 'blur' }
          ],
          inspection_user_id: [
            { required: true, message: '请选择负责人', trigger: 'change' }
          ],
          reserve_sample_num: [
            {
              required: true,
              type: 'number',
              validator: CheckNum,
              trigger: 'blur'
            }
          ],
          reserve_sample_date: [
            { required: true, message: '时间不能为空', trigger: 'change' }
          ],
          participants_user_id: [
            { required: true, message: '请选择参与人', trigger: 'change' }
          ],
          location_name: [
            { required: true, message: '请输入位置', trigger: 'blur' }
          ],
          reserve_sample_no: [
            { required: true, message: '请输入留样编号', trigger: 'blur' }
          ],
          packaging: [
            { required: true, message: '请输入留样包装', trigger: 'blur' }
          ],
          return_sample_check_num: [
            {
              required: true,
              type: 'number',
              validator: CheckNum,
              trigger: 'blur'
            }
          ],
          storage_conditions: [{ validator: checkStorage, trigger: 'change' }],
          inspection_date: [{ required: true, message: '请选择检验期限', trigger: 'change' }],
          quality_standard_file: [{ required: true, type: Array, validator: checkHandl, trigger: 'change' }],
          'tableResults.computation_sheet': [{
            required: true,
            type: Array,
            validator: checkHandl1,
            trigger: 'change'
          }],
          'tableResults.inspection_map': [{ required: true, type: Array, validator: checkHandl2, trigger: 'change' }],
          'tableResults.report.batch_no': [{ required: true, type: Array, validator: checkHandl3, trigger: 'change' }],
          old_name: [{ required: true, validator: checkHandl3, trigger: 'change' }]
        },
        inspection_status: undefined,
        inspection_joiner: [], //参与人
        rowList: {},
        openReport: false,
        fileList: [],
        fileType: undefined,
        pickerOption: {
          disabledDate(time) {
            return time.getTime() < Date.now() - 8.64e6
          }
        },
        pickerOption1: {
          disabledDate(time) {
            //此条为设置禁止用户选择今天之前的日期，包含今天。
            return time.getTime() <= Date.now() - 8.64e7
          }
        },
        userInfo: '',
        fileListData: [],
        if_result_check_back: undefined,
        demandSourceOptions: [],
        listPackaging: [],
        locationList: [],
        selectSring: '',
        if_check: 0,
        fileListQuality: [],
        projectList: [],
        ruleForm: {
          tableHead: [],
          tableData: []
        },
        statisticalData: {},
        widthPx: '800px',
        booleInfo: false,
        objData: {
          fileList: [],
          newFileList: []
        },
        objData1: {
          fileList: [],
          newFileList: []
        }
      }
    },
    //是计算属性，也可以理解为一个方法。
    computed: {
      status() {
        return function(val) {
          let a = ''
          this.inspection.forEach(element => {
            if (val == element.value) {
              a = element.label
            }
          })
          return a
        }
      },
      handlAbc() {
        return function(val) {
          let index = val.findIndex(a => a.id === this.userInfo)
          if (index !== -1) {
            return true
          } else {
            return false
          }
        }
      },
      handlBath() {
        return function(val) {
          let str = '', a = val.sample_info.batch_info
          for (let i = 0; i < a.length; i++) {
            str += a[i].sample_batch
            if (i !== a.length - 1) {
              str = str + '、'
            }
          }
          return str
        }
      },
      isHaveWho: function() {
        return this.formOpen.if_reserve_sample === 1
      }
    },
    //属性是手动定义的所需监听的值
    watch: {},

    beforeRouteEnter(to, from, next) {
      to.params.refresh = from.params.refresh
      next()
    },
    activated() {
      if (this.$route.params.refresh) {
        this.myWaitData()
      }
    },

    //生命周期 - 创建完成（访问当前this实例）
    created() {
      if (this.$route.query.research == 1) {
        this.queryParams.inspection_status = 0
      }
      this.userInfo = this.$store.getters.userInfo.user.id
      this.remoteMethod()
      this.myWaitData()
      this.handlApplyUser()
      this.handlApplyHeader()
      this.getSysAllDic()
      this.getDetailsBrandData()
      this.handleQuality()
    },
    //生命周期 - 挂载完成（访问DOM元素）
    mounted() {
    },
    //是Vue实例对象上绑定的方法，供当前Vue组件作用域内使用，
    methods: {
      //留样单选
      onChangeRadio(val) {
        this.formOpen.if_reserve_sample = val
        if (val === 2) {
          this.formOpen.storage_conditions = ''
        }
      },

      //质量标准事件
      handlRadio(val) {
        if (val === 1 || val === 2) {
          this.formOpen.quality_standard_file = []
          this.fileListQuality = []
          this.formOpen.quality_standard_id = ''
        }
      },

      //获取质量标准
      handleQuality() {
        let data = {
          condition: {
            quality_type_name: '',
            quality_source_name: '',
            quality_standard_name: '',
            quality_standard_status: 4
          },
          pager: {
            skip: 1,
            limit: 30
          }
        }
        quality(data).then(res => {
          if (res.code === 200) {
            this.projectList = res.data.data || []
          }
        })
      },

      //质量标准事件
      onChangeQuality(val) {
        this.formOpen.quality_standard_id = val
        this.projectList.forEach(item => {
          if (item.id === val) {
            this.formOpen.quality_standard_name = item.quality_standard_name
          }

        })
        viewQuality(val).then(res => {
          if (res.code === 200) {
            this.fileListQuality = res.data.file || []
            this.formOpen.quality_standard_file = res.data.file || []
          }
        })
      },

      //查看质量标准
      openFile(file) {
        filePreviewFun(file)
      },

      uploadSuccess() {
        this.formOpen.quality_standard_file = this.$refs.uploadFiles.emitFileList()
      },

      //查看质量标准
      openFile1(file) {
        filePreviewFun(file)
      },

      //删除质量标准
      handlDele(file) {
        fileDeleteFunc({ id: file.id })
          .then(_ => {
            let index = this.formOpen.quality_standard_file.findIndex(
              a => a.id === file.id
            )
            if (index !== -1) {
              this.formOpen.quality_standard_file.splice(index, 1)
            }
          })
          .catch(() => {
            this.$message({
              type: 'error',
              message: '删除失败'
            })
          })
      },

      onChangeTime2(val) {
        this.formOpen.inspection_date = `${val} 00:00:00`
      },

      //删除
      handlFile(index) {
        let aa = this.formOpen.tableResults.report[index]
        let data = {
          batch_no: aa.batch_no,//批号
          inspection_conclusion: aa.inspection_conclusion,//结论
          sample_name: aa.sample_name,//检品名称
          sample_id: aa.sample_id,//检品id
          project_id: aa.project_id,// 项目id
          project_name: aa.project_name,//项目名称
          ruleForm: aa.ruleForm,
          file_no: '',//文件编号
          file_version: ''//文件版本
        }
        this.$set(this.formOpen.tableResults.report, index, data)
        let arr = this.formOpen.tableResults.report.filter(b => b.old_name !== undefined)
        sampleUpdate({ id: this.formOpen.id, report: arr }).then(res => {
          if (res.code === 200) {
            this.myWaitData()
          } else {
            this.$message.error(res.msg)
          }
        })
      },

      //检验报告
      uploadSuccessResults(val, index) {
        for (let key in val[0]) {
          this.$set(this.formOpen.tableResults.report[index], key, val[0][key])
        }
        let aa = 'tableResults.report.' + index + '.old_name'
        if (val[0].old_name !== '') {
          this.$nextTick(_ => {
            this.$refs.formOpen.clearValidate(aa)
          })
        }

      },

      //检验报告删除
      deleteSuccess(val, index) {
        let aa = val
        let data = {
          batch_no: aa.batch_no,//批号
          inspection_conclusion: aa.inspection_conclusion,//结论
          sample_name: aa.sample_name,//检品名称
          sample_id: aa.sample_id,//检品id
          project_id: aa.project_id,// 项目id
          project_name: aa.project_name,//项目名称
          ruleForm: aa.ruleForm,
          file_no: '',//文件编号
          file_version: ''//文件版本
        }
        this.$set(this.formOpen.tableResults.report, index, data)
      },

      //计算表格
      uploadComputation() {
        let val = this.$refs.computation_sheet.fileList
        for (let i = 0; i < val.length; i++) {
          val[i] = { ...val[i], ...this.basisData }
        }
        this.formOpen.tableResults.computation_sheet = val
        if (val.length > 0) {
          this.$nextTick(_ => {
            this.$refs.formOpen.clearValidate('tableResults.computation_sheet')
          })
        }
      },

      //
      selectSuccess(obj) {
        this.objData = obj
        if (obj.fileList.length > 0 || obj.newFileList.length > 0) {
          this.$nextTick(_ => {
            this.$refs.formOpen.clearValidate('tableResults.computation_sheet')
          })
        }
      },

      selectSuccess1(obj) {
        this.objData1 = obj
        if (obj.fileList.length > 0 || obj.newFileList.length > 0) {
          this.$nextTick(_ => {
            this.$refs.formOpen.clearValidate('tableResults.inspection_map')
          })
        }
      },

      //检验图谱
      uploadInspection() {
        let val = this.$refs.inspection_map.fileList
        for (let i = 0; i < val.length; i++) {
          val[i] = { ...val[i], ...this.basisData }
        }
        this.formOpen.tableResults.inspection_map = val
        if (val.length > 0) {
          this.$nextTick(_ => {
            this.$refs.formOpen.clearValidate('tableResults.inspection_map')
          })
        }
      },

      //留样包装
      async querySearchAsync(queryString, cb) {
        let res = await samplePackaging('')
        if (res.code === 200) {
          this.listPackaging = res.data
        } else {
          this.listPackaging = []
        }
        let results = this.listPackaging
        cb(results)
      },

      handlPackaging(val) {
        if (val) {
          this.formOpen.packaging = val.packing_material_name
          this.$nextTick(_ => {
            this.$refs.formOpen.clearValidate('packaging')
          })
        }
      },

      //获取
      remoteMethods(query) {
        if (query) {
          this.formOpen.location_name = query
        }
      },

      //获取
      getDetailsBrandData() {
        let that = this
        sampleLocation('').then(res => {
          if (res.code === 200) {
            that.locationList = res.data || []
          }
        })
      },

      //品牌
      selectClick(val) {
        this.formOpen.location_name = val
      },

      getSysAllDic() {
        lookInfoSet({ dictType: 'inspection_type' }).then(res => {
          if (res.code === 200) {
            this.demandSourceOptions = res.data
          }
        })
      },
      //参与人
      handlApplyUser() {
        let data = {
          code: 'Checker'
        }
        applyUser(data).then(res => {
          if (res.code === 200) {
            this.participants = res.data
          }
        })
      },

      //负责人
      handlApplyHeader() {
        let data = {
          code: 'Checker'
        }
        applyHeader(data).then(res => {
          if (res.code === 200) {
            this.inspector = res.data
          }
        })
      },

      //项目名臣
      async remoteMethod(queryString) {
        let res = await projectNamesss()
        if (res.code === 200) {
          this.project = res.data.data || []
        }
      },

      //获取列表
      myWaitData() {
        myWait(this.queryParams).then(res => {
          if (res.code === 200) {
            this.myWaitList = res.data.data || []
            this.total = res.data.total
          }
        })
      },

      //页码
      pagination(val) {
        this.queryParams.pager.skip = val.page
        this.queryParams.pager.limit = val.limit
        this.myWaitData()
      },

      handlSearch(val) {
        this.queryParams.search_type = val
        this.queryParams.pager.skip = 1
        this.myWaitData()
      },

      handlInspection(val) {
        this.queryParams.inspection_type = val
        this.queryParams.pager.skip = 1
        this.myWaitData()
      },

      handlProject(val) {
        this.queryParams.project_id = val
        this.queryParams.pager.skip = 1
        this.myWaitData()
      },

      handlSatus(val) {
        this.queryParams.inspection_status = val
        this.queryParams.pager.skip = 1
        this.myWaitData()
      },

      //搜索
      handleQuery() {
        this.queryParams.pager.skip = 1
        this.myWaitData()
      },

      //重置
      resetQuery() {
        this.queryParams = {
          inspection_type: undefined,
          project_id: '',
          inspection_status: -1,
          search_type: 0,
          pager: {
            limit: 10,
            skip: 1
          }
        }
        this.myWaitData()
      },

      //查看详情
      handlDetails(id) {
        this.$router.push({
          path: '/sampleInspection/details',
          query: { type: 2, id: id }
        })
      },

      //查看详情
      aloneClick(row, column, event) {
        if (column.label === '操作') {
          return
        }
        this.$router.push({
          path: '/sampleInspection/taskDetails',
          query: { id: row.id }
        })
      },

      cellStyle(data) {
        return 'cursor:pointer;'
      },

      //检验员事件
      onChangeInsp(val) {
        this.formOpen.inspection_user_id = val
        this.inspector.forEach(item => {
          if (item.id === val) {
            this.formOpen.inspection_user_name = item.name
          }
        })
      },

      //参与人事件
      onChangeSelect(val) {
        let arr = []
        this.formOpen.participants_user_id = val
        this.participants.forEach(item => {
          val.forEach(id => {
            if (item.id === id) {
              arr.push({
                id: id,
                name: item.name
              })
            }
          })
        })

        this.inspection_joiner = [...new Set(arr)]
      },

      //留样位置
      onChangeLoca(val) {
        this.formOpen.location_id = val
        this.location.forEach(item => {
          if (item.value === val) {
            this.formOpen.location_name = item.label
          }
        })
      },

      //审批
      handlAnd(row) {
        let _self = this
        _self.title = '检验报告审批'
        _self.openBoole = 1
        _self.open = true
        _self.formOpen.id = row.id
      },

      //返样
      handlReturn(row) {
        console.log(row)
        let _self = this
        _self.title = '返样'
        _self.openBoole = 5
        _self.open = true
        _self.formOpen.id = row.id
        _self.rowList = row
        _self.formOpen.name = row.sample_info.name
        _self.formOpen.sample_num = row.sample_num
        _self.if_check = 1
      },

      //返样编辑
      handlReturnEdit(row) {
        let _self = this
        _self.title = '返样编辑'
        _self.openBoole = 5
        _self.open = true
        _self.formOpen.id = row.id
        _self.rowList = row
        _self.formOpen.name = row.sample_info.name
        _self.formOpen.sample_num = row.sample_num
        let a = row.return_sample_check.id
        _self.formOpen.return_sample_check_num = row.return_sample_check_num[a]
        _self.if_check = 2
      },

      //分配
      handlDistri(row) {
        let _self = this
        _self.title = '分配检验员'
        _self.openBoole = 2
        _self.open = true
        _self.rowList = row
        _self.formOpen.id = row.id
        _self.formOpen.if_reserve_sample = row.if_reserve_sample

      },

      //留样
      handlReten(row) {
        let _self = this
        _self.title = '留样'
        _self.openBoole = 3
        _self.open = true
        _self.formOpen.id = row.id
        _self.rowList = row
      },

      //留样数量事件
      handlSampleNum(val) {
        this.formOpen.reserve_sample_num = Number(val)
      },

      //提交检验结果
      handlResults(row) {
        this.widthPx = '1200px'
        if (row.reserve_sample_opt === false && row.if_reserve_sample === 1) {
          this.$message.error('请先留样')
          return
        }
        this.formOpen.tableResults = {
          computation_sheet: [],
          report: [],
          inspection_map: []
        }
        this.rowList = row
        let _self = this
        if (row.computation_sheet && row.inspection_result && row.inspection_map) {
          _self.formOpen.tableResults.computation_sheet = JSON.parse(JSON.stringify(row.computation_sheet)) || []
          _self.formOpen.tableResults.report = JSON.parse(JSON.stringify(row.inspection_result)) || []
          _self.formOpen.tableResults.inspection_map = JSON.parse(JSON.stringify(row.inspection_map)) || []
          _self.objData.fileList = _self.formOpen.tableResults.inspection_map
          _self.objData1.fileList = _self.formOpen.tableResults.computation_sheet
          for (let i = 0; i < _self.formOpen.tableResults.report.length; i++) {
            _self.formOpen.tableResults.report[i].boole = true
          }
        }
        if (row.sample_info) {
          let data = {}, a = row.sample_info.batch_info
          for (let i = 0; i < a.length; i++) {
            data = {
              batch_no: a[i].sample_batch,//批号
              inspection_conclusion: 1,//结论
              sample_name: row.sample_info.name,//检品名称
              sample_id: row.sample_info.id,//检品id
              project_id: row.project_id,// 项目id
              project_name: row.project_name,//项目名称
              file_no: '',//文件编号
              ruleForm: {},
              file_version: ''//文件版本
            }
            let index = _self.formOpen.tableResults.report.findIndex(b => b.batch_no === a[i].sample_batch)
            if (index === -1) {
              _self.formOpen.tableResults.report.push(data)
            }
          }
        }
        _self.basisData = {
          sample_name: row.sample_info.name,//检品名称
          sample_id: row.sample_info.id,//检品id
          project_id: row.project_id,// 项目id
          project_name: row.project_name//项目名称
        }
        _self.title = '上传检验报告'
        _self.openBoole = 4
        _self.formOpen.id = row.id
        _self.formOpen.relation_plan_id = row.relation_plan_id
        _self.formOpen.tableResults.id = row.id
        _self.if_result_check_back = row.if_result_check_back
        _self.activeNames = _self.formOpen.tableResults.report[0].batch_no
        _self.handlRule(row)
      },

      //
      handlRule(row) {
        if (row.inspection_type === 'inspection_type_wd') {
          sampleListTable({ id: row.relation_plan_id }).then(res => {
            if (res.code === 200) {
              this.formOpen.tableResults.report.forEach(item => {
                if (res.data && res.data[item.batch_no] !== null) {
                  let aaa = JSON.parse(JSON.stringify(res.data[item.batch_no]))
                  this.$set(item, 'ruleForm', aaa)
                }
              })
            }
          })
        }
        setTimeout(_ => {
          this.open = true
        }, 200)
      },

      //撤销
      handlUndo(id) {
        this.$confirm('确认要撤销', '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(_ => {
            undo(id).then(res => {
              if (res.code === 200) {
                this.$message.success('操作成功')
                this.myWaitData()
              } else {
                this.$message.error(res.msg)
              }
            })
          })
          .catch(_ => {
          })
      },

      //查看报告
      handlReport(id, row) {
        this.openReport = true
        this.rowList = row
        this.formOpen.tableResults = {
          computation_sheet: [],
          report: [],
          inspection_map: []
        }
        if (row.computation_sheet && row.inspection_result && row.inspection_map) {
          this.formOpen.tableResults.computation_sheet = JSON.parse(JSON.stringify(row.computation_sheet)) || []
          this.formOpen.tableResults.report = JSON.parse(JSON.stringify(row.inspection_result)) || []
          this.formOpen.tableResults.inspection_map = row.inspection_map || []
          for (let i = 0; i < this.formOpen.tableResults.report.length; i++) {
            this.formOpen.tableResults.report[i].boole = true
            if (row.experiment_table_info_map) {
              this.formOpen.tableResults.report[i].ruleForm = row.experiment_table_info_map[this.formOpen.tableResults.report[i].batch_no]
            } else {
              if (row.inspection_type === 'inspection_type_wd') {
                sampleListTable({ id: row.relation_plan_id }).then(res => {
                  if (res.code === 200) {
                    this.formOpen.tableResults.report.forEach(item => {
                      if (res.data[item.batch_no]) {
                        item.ruleForm = res.data[item.batch_no]
                      }
                    })
                  }
                })
              }
            }
          }
        }
        this.activeNames = this.formOpen.tableResults.report[0].batch_no
      },

      //撤销审批
      cancelOperation(row) {
        const subdata = {
          flow_id: row.result_check.id,
          model_type: 'CheckResult'
        }
        this.$comFun.cancelFunc(subdata)
          .then(() => {
            this.$message({
              type: 'success',
              message: '已撤销'
            })
            this.myWaitData()
          })
          .catch(err => {
            this.$message.error(err)
          })
      },

      //取消
      cancel() {
        this.open = false
        this.booleInfo = false
        this.formOpen = {
          id: '0', //主键id
          check_status: undefined, //审批 1 通过  2 拒绝
          check_advice: '', //审批建议
          inspection_user_id: '', //分配的检验员的id
          inspection_user_name: '', //分配的检验员的名称
          reserve_sample_num: undefined, //留样的数量
          reserve_sample_date: '', //留样的有效期
          report: '', //报告内容
          participants_user_id: [], //参与人id
          participants_user_name: [], //参与人名字
          location_id: '', //位置id
          location_name: '', //位置name
          reserve_sample_no: '', //留样编号
          packaging: '', //留样包装
          inspection_conclusion: 1,
          remark: '',
          sample_num: null,
          return_sample_check_num: null,
          name: '',
          if_reserve_sample: 1,
          storage_conditions: '',
          quality_standard_type: 1,
          quality_standard_id: '',
          quality_standard_name: '',
          quality_standard_file: [],
          inspection_date: '',
          tableResults: {
            id: '',
            report: [],//
            computation_sheet: [], //计算表格
            inspection_map: []//  检验图谱
          }
        }
        this.inspection_joiner = []
        this.sample_info = [] //样品信息
        this.apply_inspection_user = [] //检验负责人
        this.inspection_user = {} //请检人
        this.myWaitData()
      },

      //拒绝
      refused() {
        this.$refs.formOpen.validate(valid => {
          if (valid) {
            let commit = undefined,
              data = {},
              msg = ''
            commit = reportCheck
            data = {
              id: this.formOpen.id,
              check_status: 2,
              check_advice: this.formOpen.check_advice
            }
            msg = this.title + '已拒绝'
            commit(data).then(res => {
              if (res.code === 200) {
                this.$message.success(msg)
                this.open = false
                this.cancel()
                this.myWaitData()
              } else {
                this.$message.error(res.msg)
              }
            })
          } else {
            return false
          }
        })
      },

      //提交
      submitForm() {
        let _self = this
        _self.$refs.formOpen.validate(async valid => {
          if (valid) {
            let commit = undefined,
              data = {},
              msg = ''
            switch (this.openBoole) {
              case 1:
                commit = reportCheck
                data = {
                  id: _self.formOpen.id,
                  check_status: 1,
                  check_advice: _self.formOpen.check_advice
                }
                msg = _self.title + '已同意'
                break
              case 2:
                commit = allocation
                data = {
                  id: _self.formOpen.id,
                  inspection_header: {
                    id: _self.formOpen.inspection_user_id,
                    name: _self.formOpen.inspection_user_name
                  },
                  inspection_joiner: _self.inspection_joiner,
                  if_reserve_sample: _self.formOpen.if_reserve_sample,
                  storage_conditions: _self.formOpen.storage_conditions,
                  quality_standard_id: _self.formOpen.quality_standard_id,
                  quality_standard_name: _self.formOpen.quality_standard_name,
                  quality_standard_file: _self.formOpen.quality_standard_file,
                  quality_standard_type: _self.formOpen.quality_standard_type,
                  inspection_date: _self.formOpen.inspection_date,
                  if_stability: _self.rowList.inspection_type === 'inspection_type_wd' ? 1 : 0
                }
                msg = '操作成功'
                break
              case 3:
                commit = samples
                data = {
                  inspection_id: _self.formOpen.id,
                  expiry_date: _self.formOpen.reserve_sample_date,
                  num: Number(_self.formOpen.reserve_sample_num),
                  reserve_sample_no: _self.formOpen.reserve_sample_no,
                  sample_info: _self.rowList.sample_info,
                  apply_inspection_user: _self.rowList.inspection_header,
                  inspection_user: {
                    id: _self.rowList.creator_id,
                    name: _self.rowList.creator_name
                  },
                  location_id: _self.formOpen.location_id,
                  location_name: _self.formOpen.location_name,
                  packaging: _self.formOpen.packaging,
                  project_id: _self.rowList.project_id,
                  project_name: _self.rowList.project_name,
                  inspection_header: _self.rowList.inspection_header,
                  inspection_joiner: _self.rowList.inspection_joiner,
                  remark: _self.formOpen.remark
                }
                msg = _self.title + '已成功'
                break
              case 4:
                let dataList1 = await this.$refs.uploadEnclosure1.saveFile()
                let dataList2 = await this.$refs.uploadEnclosure2.saveFile()
                this.formOpen.tableResults.computation_sheet = dataList1[0]
                this.formOpen.tableResults.inspection_map = dataList2[0]
                let booleAbs = false, booleInfo = false, info = {}
                for (let i = 0; i < _self.formOpen.tableResults.report.length; i++) {
                  let a = JSON.parse(JSON.stringify(_self.formOpen.tableResults.report[i]))
                  let check = {
                    file_no: a.file_no,
                    file_version: a.file_version
                  }
                  if (_self.rowList.inspection_type === 'inspection_type_wd') {
                    let aa = this.formOpen.tableResults.report[i]
                    info[a.batch_no] = aa.ruleForm
                    let bo = this.$refs.statistical[i].submitFormsss()
                    if (bo !== 1) {
                      booleInfo = true
                      this.booleInfo = true
                      break
                    }
                  }
                  let res1 = await this.$api.FILE_IS_EXIST(check)
                  if (res1.code === 200) {
                    if (res1.data) {
                      let bbb = a.batch_no + '编号或者版本号重复'
                      this.$message.error(bbb)
                      booleAbs = true
                      break
                    }
                  } else {
                    this.$message.error(res1.msg)
                    booleAbs = true
                    break
                  }
                }
                if (booleAbs || booleInfo) return
                let statisticalData = {
                  id: _self.formOpen.relation_plan_id,
                  info: info
                }
                if (_self.rowList.inspection_type === 'inspection_type_wd') {
                  sampleListUpdate(statisticalData).then(res => {
                    if (res.code === 200) {
                    } else {
                      this.$message.error(res.msg)
                    }
                  })
                }

                if (_self.if_result_check_back === 1) {
                  commit = applyEditorUpdate
                }
                if (_self.if_result_check_back === 0) {
                  commit = report
                }
                data = _self.formOpen.tableResults
                msg = _self.title + '已成功'
                break
              case 5:
                if (_self.if_check === 1) {
                  commit = sampleReturn
                }
                if (_self.if_check === 2) {
                  commit = sampleReturnUpdate
                }
                data = {
                  id: _self.formOpen.id,
                  return_sample_check_num: Number(_self.formOpen.return_sample_check_num)
                }
                msg = _self.title + '已成功'
                break
            }
            _self.booleInfo = false
            let res = await commit(data)
            if (res.code === 200) {
              _self.$message.success(msg)
              if (_self.openBoole === 3) {
                sampleLocationCreate({ sample_location_name: _self.formOpen.location_name }).then(res => {
                  return
                })
              }
              _self.open = false
              _self.cancel()
              _self.myWaitData()
            } else {
              _self.$message.error(res.msg)
            }
          } else {
            this.booleInfo = true
            return false
          }
        })
      }
    }
  }
</script>
<style scoped>
  /* @import url(); 引入css类 */
  ::v-deep .el-button--text {
    padding: 0;
    margin: 0 !important;
    margin-right: 10px !important;
  }

  ::v-deep .el-collapse {
    border: none !important;
  }

  ::v-deep .manualBook .el-collapse-item__header {
    background: rgba(64, 158, 255, .1);
    margin-bottom: 15px;
    padding-left: 10px;

  }

  .tableForm ::v-deep .el-form-item {
    margin-bottom: 0 !important;
  }

  .tableBox ::v-deep td {
    padding: 0 !important;
  }

  .tableBox ::v-deep .cell {
    padding: 0 !important;
  }

  .box_table {
    border-left: 1px solid #dfe6ec;
  }

  .box_item {
    padding: 5px;
    border-bottom: 1px solid #dfe6ec;
  }

  .box_item:last-child {
    border: none !important;
  }

</style>
